package com.xiaochong.tir.api.util;

/**
 * Created by Administrator on 2018/6/14.
 */
public enum  TimeSeconds {

    m1("1min", 60), m3("3min", 180), m5("5min", 300), m15("15min", 900),m30("30min",1800),h1("1hour",3600),h2("2hour",7200),h4("4hour",14400),h6("6hour",21600),h8("8hour",28800),h12("12hour",43200)
    ,d1("1day",86400),d3("3day",259200),w1("1week",604800),M1("1mon",2592000),y1("1year",31536000),
    WEIGHT_KLINE_1D("wi1day", 1),
    WEIGHT_KLINE_1W("wi1week", 7),
    WEIGHT_KLINE_1M("wi1mon", 30),
    WEIGHT_KLINE_2M("wi2mon", 60),
    WEIGHT_KLINE_3M("wi3mon", 90),
    WEIGHT_KLINE_6M("wi6mon", 180),
    WEIGHT_KLINE_1Y("wi1year", 365);
    // 成员变量
    private String name;
    private int index;
    // 构造方法
    private TimeSeconds(String name, int index) {
        this.name = name;
        this.index = index;
    }
    // 普通方法
    public static String getName(int index) {
        for (TimeSeconds c : TimeSeconds.values()) {
            if (c.getIndex() == index) {
                return c.name;
            }
        }
        return null;
    }

    public static Integer getValue(String name) {
        for (TimeSeconds c : TimeSeconds.values()) {
            if (c.getName() .equals( name )) {
                return c.index;
            }
        }
        return null;
    }
    // get set 方法
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getIndex() {
        return index;
    }
    public void setIndex(int index) {
        this.index = index;
    }
}
